# _*_ coding:utf-8 _*_
# @Time : 2023/5/25 17:57
# @Author : wsl
# @File : day05_demo
# @Project : python  异常

import urllib.request
import urllib.error

# 域名或者后面的接口错误
url = 'https://blog.csdn.net/whiteBearClimb/article/details/110952834?'

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/113.0'
}

try:
    request1 = urllib.request.Request(url=url, headers=headers)
    response = urllib.request.urlopen(request1)
    content1 = response.read().decode('utf‐8')
    print(content1)
except urllib.error.HTTPError:
    print('HTTPError，系统...')
except urllib.error.URLError:
    print('URLError，系统...')
else:
    print('没有异常')
